package com.readEvent;

import lombok.extern.slf4j.Slf4j;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.nio.channels.SocketChannel;
import java.nio.charset.StandardCharsets;

/**
 * @author 罗俊华
 * @date 2021/8/23 - 3:03 下午
 */
@Slf4j
public class Client {

    public static void main(String[] args) throws IOException {

        InetSocketAddress inetSocketAddress = new InetSocketAddress(9090);

        SocketChannel socketChannel = SocketChannel.open(inetSocketAddress);


        log.debug("已连接到服务器，并打开通道：{}", socketChannel);

        socketChannel.write(StandardCharsets.UTF_8.encode("hello\nworld\n"));

        log.debug("写入成功！");

    }
}
